Skip to content

Conversation

dkolsen-pgi
Copy link
Contributor

In #128754, DataLayoutTypeInterface was changed to give getPreferredAlignment a default implemention. As a result, table-gen no longer declared getPreferredAlignment when defining a class that contained [DeclareTypeInterfaceMethods<DataLayoutTypeInterface>] in the table-gen definition. That means all of the definitions in CIRTypes.cpp, such as PointerType::getPreferredAligment, were compilation errors.

Delete all the definitions of getPreferredAlignment. I verified that the default implementation does the exact same thing as the explicit overrides that are being deleted.

In llvm#128754, `DataLayoutTypeInterface` was changed to give
`getPreferredAlignment` a default implemention.  As a result, table-gen
no longer declared `getPreferredAlignment` when defining a class that
contained `[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]` in
the table-gen definition.  That means all of the definitions in
`CIRTypes.cpp`, such as `PointerType::getPreferredAligment`, were
compilation errors.

Delete all the definitions of `getPreferredAlignment`.  I verified that
the default implementation does the exact same thing as the explicit
overrides that are being deleted.
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Feb 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2025

@llvm/pr-subscribers-clang

Author: David Olsen (dkolsen-pgi)

Changes

In #128754, DataLayoutTypeInterface was changed to give getPreferredAlignment a default implemention. As a result, table-gen no longer declared getPreferredAlignment when defining a class that contained [DeclareTypeInterfaceMethods&lt;DataLayoutTypeInterface&gt;] in the table-gen definition. That means all of the definitions in CIRTypes.cpp, such as PointerType::getPreferredAligment, were compilation errors.

Delete all the definitions of getPreferredAlignment. I verified that the default implementation does the exact same thing as the explicit overrides that are being deleted.


Full diff: https://github.com/llvm/llvm-project/pull/128772.diff

1 Files Affected:

  • (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (-62)
diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index f3349250f2205..d1b143efb955e 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -125,12 +125,6 @@ uint64_t IntType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-IntType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                               ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 mlir::LogicalResult
 IntType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                 unsigned width, bool isSigned) {
@@ -163,12 +157,6 @@ SingleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-SingleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &DoubleType::getFloatSemantics() const {
   return llvm::APFloat::IEEEdouble();
 }
@@ -185,12 +173,6 @@ DoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-DoubleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP16Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEhalf();
 }
@@ -206,12 +188,6 @@ uint64_t FP16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-FP16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &BF16Type::getFloatSemantics() const {
   return llvm::APFloat::BFloat();
 }
@@ -227,12 +203,6 @@ uint64_t BF16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-BF16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP80Type::getFloatSemantics() const {
   return llvm::APFloat::x87DoubleExtended();
 }
@@ -249,12 +219,6 @@ uint64_t FP80Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP80Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &FP128Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEquad();
 }
@@ -270,12 +234,6 @@ uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP128Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                 ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const {
   return mlir::cast<cir::CIRFPTypeInterface>(getUnderlying())
       .getFloatSemantics();
@@ -295,13 +253,6 @@ LongDoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
       .getABIAlignment(dataLayout, params);
 }
 
-uint64_t LongDoubleType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    mlir::DataLayoutEntryListRef params) const {
-  return mlir::cast<mlir::DataLayoutTypeInterface>(getUnderlying())
-      .getPreferredAlignment(dataLayout, params);
-}
-
 LogicalResult
 LongDoubleType::verify(function_ref<InFlightDiagnostic()> emitError,
                        mlir::Type underlying) {
@@ -397,12 +348,6 @@ BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 1;
 }
 
-uint64_t
-BoolType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 1;
-}
-
 //===----------------------------------------------------------------------===//
 // PointerType Definitions
 //===----------------------------------------------------------------------===//
@@ -421,13 +366,6 @@ PointerType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 8;
 }
 
-uint64_t PointerType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    ::mlir::DataLayoutEntryListRef params) const {
-  // FIXME: improve this in face of address spaces
-  return 8;
-}
-
 mlir::LogicalResult
 PointerType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                     mlir::Type pointee) {

@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2025

@llvm/pr-subscribers-clangir

Author: David Olsen (dkolsen-pgi)

Changes

In #128754, DataLayoutTypeInterface was changed to give getPreferredAlignment a default implemention. As a result, table-gen no longer declared getPreferredAlignment when defining a class that contained [DeclareTypeInterfaceMethods&lt;DataLayoutTypeInterface&gt;] in the table-gen definition. That means all of the definitions in CIRTypes.cpp, such as PointerType::getPreferredAligment, were compilation errors.

Delete all the definitions of getPreferredAlignment. I verified that the default implementation does the exact same thing as the explicit overrides that are being deleted.


Full diff: https://github.com/llvm/llvm-project/pull/128772.diff

1 Files Affected:

  • (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (-62)
diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index f3349250f2205..d1b143efb955e 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -125,12 +125,6 @@ uint64_t IntType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-IntType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                               ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 mlir::LogicalResult
 IntType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                 unsigned width, bool isSigned) {
@@ -163,12 +157,6 @@ SingleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-SingleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &DoubleType::getFloatSemantics() const {
   return llvm::APFloat::IEEEdouble();
 }
@@ -185,12 +173,6 @@ DoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-DoubleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP16Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEhalf();
 }
@@ -206,12 +188,6 @@ uint64_t FP16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-FP16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &BF16Type::getFloatSemantics() const {
   return llvm::APFloat::BFloat();
 }
@@ -227,12 +203,6 @@ uint64_t BF16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-BF16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP80Type::getFloatSemantics() const {
   return llvm::APFloat::x87DoubleExtended();
 }
@@ -249,12 +219,6 @@ uint64_t FP80Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP80Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &FP128Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEquad();
 }
@@ -270,12 +234,6 @@ uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP128Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                 ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const {
   return mlir::cast<cir::CIRFPTypeInterface>(getUnderlying())
       .getFloatSemantics();
@@ -295,13 +253,6 @@ LongDoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
       .getABIAlignment(dataLayout, params);
 }
 
-uint64_t LongDoubleType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    mlir::DataLayoutEntryListRef params) const {
-  return mlir::cast<mlir::DataLayoutTypeInterface>(getUnderlying())
-      .getPreferredAlignment(dataLayout, params);
-}
-
 LogicalResult
 LongDoubleType::verify(function_ref<InFlightDiagnostic()> emitError,
                        mlir::Type underlying) {
@@ -397,12 +348,6 @@ BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 1;
 }
 
-uint64_t
-BoolType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 1;
-}
-
 //===----------------------------------------------------------------------===//
 // PointerType Definitions
 //===----------------------------------------------------------------------===//
@@ -421,13 +366,6 @@ PointerType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 8;
 }
 
-uint64_t PointerType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    ::mlir::DataLayoutEntryListRef params) const {
-  // FIXME: improve this in face of address spaces
-  return 8;
-}
-
 mlir::LogicalResult
 PointerType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                     mlir::Type pointee) {

@dkolsen-pgi
Copy link
Contributor Author

@bcardosolopes @lanza You will run into this same problem with the next incubator rebase. The fix should be the same, though there will be more getPreferredAlignment functions to delete.

@dkolsen-pgi
Copy link
Contributor Author

I am merging this now because it fixes a build breakage. If I messed up, it is easy enough to undo.

@dkolsen-pgi dkolsen-pgi merged commit ad94af9 into llvm:main Feb 25, 2025
11 of 13 checks passed
@lanza
Copy link
Member

lanza commented Feb 25, 2025

@bcardosolopes @lanza You will run into this same problem with the next incubator rebase. The fix should be the same, though there will be more getPreferredAlignment functions to delete.

Nice, thanks for the heads up.

bcardosolopes pushed a commit to bcardosolopes/llvm-project that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants